home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_HDF.idb / usr / freeware / include / hdf / df.h.z / df.h
Encoding:
C/C++ Source or Header  |  1999-01-26  |  7.3 KB  |  213 lines

  1. /****************************************************************************
  2.  * NCSA HDF                                                                 *
  3.  * Software Development Group                                               *
  4.  * National Center for Supercomputing Applications                          *
  5.  * University of Illinois at Urbana-Champaign                               *
  6.  * 605 E. Springfield, Champaign IL 61820                                   *
  7.  *                                                                          *
  8.  * For conditions of distribution and use, see the accompanying             *
  9.  * hdf/COPYING file.                                                        *
  10.  *                                                                          *
  11.  ****************************************************************************/
  12.  
  13. /* $Id: df.h,v 1.14 1996/03/28 21:57:07 koziol Exp $ */
  14.  
  15. /*-----------------------------------------------------------------------------
  16.  * File:    df.h
  17.  * Purpose: header file for HDF routines
  18.  * Invokes: dfi.h
  19.  * Contents:
  20.  *  Structure definitions: DFddh, DFdd, DFdesc, DFdle, DF, DFdi, DFdata
  21.  *  Procedure type definitions
  22.  *  Global variables
  23.  *  Tag definitions
  24.  *  Error return codes
  25.  *  Logical constants
  26.  * Remarks: This file is included with user programs
  27.  *          Since it includes stdio.h etc., do not include these after df.h
  28.  *---------------------------------------------------------------------------*/
  29.  
  30. #ifndef DF_H    /* avoid re-inclusion */
  31. #define DF_H
  32.  
  33. /* include DF (internal) header information */
  34. #include "hdf.h"
  35.  
  36. /*-------------------------------------------------------------------------*/
  37. /*                      Type declarations                                   */
  38.  
  39. typedef struct DFddh
  40.   {                             /*format of data descriptor headers in file */
  41.       int16       dds;          /* number of dds in header block */
  42.       int32       next;         /* offset of next header block */
  43.   }
  44. DFddh;
  45.  
  46. typedef struct DFdd
  47.   {                             /* format of data descriptors as in file */
  48.       uint16      tag;          /* data tag */
  49.       uint16      ref;          /* data reference number */
  50.       int32       offset;       /* offset of data element in file */
  51.       int32       length;       /* number of bytes */
  52.   }
  53. DFdd;
  54.  
  55. /* descriptor structure is same as dd structure.  ###Note: may be changed */
  56. typedef DFdd DFdesc;
  57.  
  58. /* DLE is the internal structure which stores data descriptor information */
  59. /* It is a linked list of DDs */
  60. typedef struct DFdle
  61.   {                             /* Data List element */
  62.       struct DFdle *next;       /* link to next dle */
  63.       DFddh       ddh;          /* To store headers */
  64.       DFdd        dd[1];        /* dummy size */
  65.   }
  66. DFdle;
  67.  
  68. /* DF is the internal structure associated with each DF file */
  69. /* It holds information associated with the file as a whole */
  70. /* ### Note: there are hooks for having multiple DF files open at a time */
  71. typedef struct DF
  72.   {
  73.       DFdle      *list;         /* Pointer to the DLE list */
  74.       DFdle      *last_dle;     /* last_dle and last_dd are used in searches */
  75.       /* to indicate element returned */
  76.       /* by previous call to DFfind */
  77.       DFdd       *up_dd;        /* DD of element being read/updated, */
  78.       /* used by DFstart */
  79.       uint16      last_tag;     /* Last tag searched for by DFfind */
  80.       uint16      last_ref;     /* Last reference number searched for */
  81.       intn        type;         /* 0= not in use, 1= normal, -1 = multiple */
  82.       /* this is a hook for when */
  83.       /* multiple files are open */
  84.       intn        access;       /* permitted access types: */
  85.       /* 0=none, 1=r, 2=w, 3=r/w */
  86.       intn        changed;      /* True if anything in DDs modified */
  87.       /* since last write */
  88.       intn        last_dd;      /* see last_dle */
  89.       intn        defdds;       /* default numer of DD's in each block */
  90.       intn        up_access;    /* access permissions to element being */
  91.       /* read/updated. Used by DFstart */
  92.       /* File handle is a file pointer or file descriptor depending on whether */
  93.       /* we use buffered or unbuffered I/O.  But, since this structure is a */
  94.       /* fake, it doesn't matter whether I/O is buffered or not. */
  95.       intn        file;         /* file descriptor */
  96.   }
  97. DF;
  98.  
  99. typedef struct DFdata
  100.   {                             /* structure for returning status information */
  101.       int32       version;      /* version number of program */
  102.   }
  103. DFdata;
  104.  
  105. /*--------------------------------------------------------------------------*/
  106. /*                          Procedure types                                 */
  107.  
  108. #if defined c_plusplus || defined __cplusplus
  109. extern      "C"
  110. {
  111. #endif                          /* c_plusplus || __cplusplus */
  112.  
  113. /* prototypes for dfstubs.c */
  114.     extern DF  *DFopen
  115.                 (char *name, int acc_mode, int ndds);
  116.  
  117.     extern int  DFclose
  118.                 (DF * dfile);
  119.  
  120.     extern int  DFdescriptors
  121.                 (DF * dfile, DFdesc ptr[], int begin, int num);
  122.  
  123.     extern int  DFnumber
  124.                 (DF * dfile, uint16 tag);
  125.  
  126.     extern int  DFsetfind
  127.                 (DF * dfile, uint16 tag, uint16 ref);
  128.  
  129.     extern int  DFfind
  130.                 (DF * dfile, DFdesc * ptr);
  131.  
  132.     extern int  DFaccess
  133.                 (DF * dfile, uint16 tag, uint16 ref, char *acc_mode);
  134.  
  135.     extern int  DFstart
  136.                 (DF * dfile, uint16 tag, uint16 ref, char *acc_mode);
  137.  
  138.     extern int32 DFread
  139.                 (DF * dfile, char *ptr, int32 len);
  140.  
  141.     extern int32 DFseek
  142.                 (DF * dfile, int32 offset);
  143.  
  144.     extern int32 DFwrite
  145.                 (DF * dfile, char *ptr, int32 len);
  146.  
  147.     extern int  DFupdate
  148.                 (DF * dfile);
  149.  
  150.     extern int  DFstat
  151.                 (DF * dfile, DFdata * dfinfo);
  152.  
  153.     extern int32 DFgetelement
  154.                 (DF * dfile, uint16 tag, uint16 ref, char *ptr);
  155.  
  156.     extern int32 DFputelement
  157.                 (DF * dfile, uint16 tag, uint16 ref, char *ptr, int32 len);
  158.  
  159.     extern int  DFdup
  160.                 (DF * dfile, uint16 itag, uint16 iref, uint16 otag, uint16 oref);
  161.  
  162.     extern int  DFdel
  163.                 (DF * dfile, uint16 tag, uint16 ref);
  164.  
  165.     extern uint16 DFnewref
  166.                 (DF * dfile);
  167.  
  168.     extern int  DFishdf
  169.                 (char *filename);
  170.  
  171.     extern int  DFerrno
  172.                 (void);
  173.  
  174.     extern int  DFIerr
  175.                 (DF * dfile);
  176.  
  177.     extern int  DFImemcopy
  178.                 (char *from, char *to, int length);
  179.  
  180.     extern void *DFIgetspace
  181.                 (uint32 qty);
  182.  
  183.     extern void *DFIfreespace
  184.                 (void *ptr);
  185.  
  186.     extern int  DFIc2fstr
  187.                 (char *str, int len);
  188.  
  189.     extern char *DFIf2cstring
  190.                 (_fcd fdesc, intn len);
  191.  
  192. /* prototypes for dfconv.c */
  193.     extern int  DFconvert
  194.                 (uint8 *source, uint8 *dest, int ntype, int sourcetype, int desttype, int32 size);
  195.  
  196. #if defined c_plusplus || defined __cplusplus
  197. }
  198. #endif                          /* c_plusplus || __cplusplus */
  199.  
  200. /*--------------------------------------------------------------------------*/
  201. /*                          Global Variables                                */
  202.  
  203. #ifndef DFMASTER
  204. extern
  205. #endif                          /*DFMASTER */
  206. int DFerror;            /* Error code for DF routines */
  207.  
  208. #define DFSETERR(error) (DFerror=(DFerror?DFerror:error))
  209.  
  210. #define DFTOFID(df) (int32)(df->list)
  211.  
  212. #endif /* DF_H */
  213.